package com.muyu.product.domain;

import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.product.domain.req.AttributeGroupQueryReq;
import com.muyu.product.domain.req.AttributeGroupSaveReq;
import com.muyu.product.domain.req.AttributeGroupEditReq;
import com.muyu.common.core.web.domain.BaseEntity;

/**
 * 属性组对象 attribute_group
 *
 * @author DongZeLiang
 * @date 2024-02-27
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("attribute_group")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "AttributeGroup", description = "属性组")
public class AttributeGroup extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /** 属性组编号 */
    @TableId(value = "id",type = IdType.AUTO)
    @ApiModelProperty(name = "属性组编号", value = "属性组编号")
    private Long id;

    /** 组名称 */
    @Excel(name = "组名称")
    @ApiModelProperty(name = "组名称", value = "组名称", required = true)
    private String name;

    /** 状态 */
    @Excel(name = "状态")
    @ApiModelProperty(name = "状态", value = "状态", required = true)
    private String states;


    /**
    * 查询构造器
    */
    public static AttributeGroup queryBuild( AttributeGroupQueryReq attributeGroupQueryReq){
        return AttributeGroup.builder()
                .name(attributeGroupQueryReq.getName())
                .states(attributeGroupQueryReq.getStates())
                .build();
    }

    /**
    * 添加构造器
    */
    public static AttributeGroup saveBuild(AttributeGroupSaveReq attributeGroupSaveReq){
        return AttributeGroup.builder()
                .name(attributeGroupSaveReq.getName())
                .states(attributeGroupSaveReq.getStates())
                .build();
    }

    /**
    * 修改构造器
    */
    public static AttributeGroup editBuild(Long id, AttributeGroupEditReq attributeGroupEditReq){
        return AttributeGroup.builder()
            .id(id)
                .name(attributeGroupEditReq.getName())
                .states(attributeGroupEditReq.getStates())
                .build();
    }

}
